//
//  todayTopicCell.m
//  Cup
//
//  Created by dllo on 15/4/24.
//  Copyright (c) 2015年 doll. All rights reserved.
//

#import "todayTopicCell.h"
#define WIDTH self.contentView.frame.size.width
@implementation todayTopicCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.userImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.userImageView];
        [self.userImageView release];
        
        self.nameLabel = [[UILabel alloc] init];
        self.nameLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.nameLabel];
        [self.nameLabel release];
        
        self.timeLabel = [[UILabel alloc] init];
        self.timeLabel.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:self.timeLabel];
        [self.timeLabel release];
        
        self.contentLabel = [[UILabel alloc] init];
        self.contentLabel.font = [UIFont systemFontOfSize:12];
        self.contentLabel.numberOfLines = 0;
        [self.contentLabel sizeToFit];
        [self.contentView addSubview:self.contentLabel];
        [self.contentLabel release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.userImageView.frame = CGRectMake(30, 20, 50, 50);
    self.userImageView.clipsToBounds = YES;
    self.userImageView.layer.cornerRadius = 25;
    
    self.nameLabel.frame = CGRectMake(93, 15, 200, 30);
    
    self.timeLabel.frame = CGRectMake(93, 40, 150, 30);
    
    NSDictionary *dicContent = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:12],NSFontAttributeName, nil];
    CGRect rectContent = [self.contentLabel.text boundingRectWithSize:CGSizeMake(WIDTH - 60, 400) options:NSStringDrawingUsesLineFragmentOrigin attributes:dicContent context:nil];
    self.contentLabel.frame = CGRectMake(30, 90,WIDTH - 60 , rectContent.size.height);
}

- (void)dealloc
{
    [_userImageView release];
    [_nameLabel release];
    [_timeLabel release];
    [_contentLabel release];
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
